home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Deutsche Edition 1
/
Deutsche Edition 1.iso
/
amok
/
001-010
/
amok08
/
iff8svxload
/
iff8svxload.readme
< prev
next >
Wrap
Text File
|
1993-11-04
|
8KB
|
221 lines
IFF8SVXLoad
==================
© 1988 by Fridtjof Siebert
Nobileweg 67
D-7000 Stuttgart-40
IFF8SVXLoad exports some procedures to load and play digitized sounds.
Load a Sampled Sound:
-------------------------
PROCEDURE Read8SVX(Name: ARRAY OF CHAR;
MaxChunkSize: LONGCARD;
ChipMem: BOOLEAN):
IFF8SVXInfoPtr;
This procedure loads the sound named Name. It's data is saved in
blocks that are MaxChunkSize big. A MaxChunkSize of 0 lets
Read8SVX() allocate a single memorychunk for each octave. This
can cause problems with big sounds. ChipMem specifies whether the
blocks are in ChipMem. If so they can be played easier, because
there's no need for doublebuffering and to copy them to chipmem.
Read8SVX()'s result is a pointer to an IFF8SVXLoad.IFF8SVXInfo. This
Record contains all loaded data. In case of any error, the result
will be NIL. More information about the error can be got via the
variable IFF8SVXLoad.IFF8SVXError.
There can be some problems when you want to load a long sound and you
have selected a small MaxChunkSize and your Stack is not especially
big. There can occur some strange errors like Address, Stack Overflow
and even the Guru!!!
Deallocate Sampled Sound's Memory:
--------------------------------------
PROCEDURE Dealloc8SVX(Info:IFF8SVXInfoPtr);
Dealloc8SVX() frees Info's Memory.
Open Audio-Device:
------------------------
To play a sound, you first have to open the Audio-Device. This is
done by the procedure OpenAudio:
PROCEDURE OpenAudio(Channels: CARDINAL; Priority: Byte): BOOLEAN;
Channels specifies how many channels to allocate. There are up to 4
channels possible. Priority sets the allocation priority, that ranges
from -128 (lowest) to 127 (highest priority).
OpenAudio()'s result is TRUE, if successful and FALSE if any error
occured. Information on the error can be got from IFF8SVXError.
Play sampled sounds:
------------------------
Having opened the audio-device, you can play the loaded sound:
PROCEDURE PlaySample(Info: IFF8SVXInfoPtr;
Octave: INTEGER;
Repeat: CARDINAL;
Channel: CARDINAL): BOOLEAN;
Info is the pointer Read8SVX() gave you. Octave selects the octave of
the sound, you want to play. It can be a value between 0 and 7. Apart
from instruments, sampled sounds have normally just one octave (#0).
Repeat selects how often to repeat a sampled sound. 1 plays it just
one time. Channel selects the soundchannel. Channel is a value between
zero and the number of allocated channels minus 1.
If PlaySample was successful, it returns TRUE, else FALSE. More
detailed information on the error occur in IFF8SVXError.
PlaySample() plays the sound with a second task, that feeds the
Audio-Device with the data it copies from Fast-memory to Chip-memory.
The memory-chunk copied each time is MaxChunkSize bytes big. IF
MaxChunkSize is too small, there can be some problems in timing.
While you play a sound, your main programm can continue doing other
things. You can play different sounds on different channels at the
same time by calling PlaySample() several times. If you call
PlaySample with a channel that plays a sound at the moment, you will
replace the played by the new one immediately.
It is possible to play the same sound on all channels at the same
time. Only high sampling rates and / or too small MaxChunkSizes can
cause small problems. There will be some `clicks' while you here your
sound.
You are not allowed to deallocate a sounds memory with Dealloc8SVX()
while the sound is playing.
Wait for a sound to complete:
---------------------------------
PROCEDURE WaitPlay(Channel: CARDINAL);
WaitPlay() waits for the sound played in Channel[Channel] to finish.
If you select IFF8SVXLoad.AllChannels as Channel, WaitPlay will wait
for all channels to finish.
In fact, WaitPlay() returns a short time before a sound finishes.
There is just one more block of data to play. This enables you to play
a second sound directly after another sound without a pause.
Close the Audio-Device:
----------------------------
PROCEDURE CloseAudio();
CloseAudio() closes the Audio-Device and stops the task that plays the
sounds. All playing sounds are stopped.
Information on Variables and Types:
---------------------------------------
IFF8SVXInfo:
Data of a sampled sound is saved into variables of this type. It
contains a big RECORD, which has got many Sub-RECORDs.
If you just want to play some sounds you won't have to know anything
about the contents of this variable.
IFF8SVXInfo.loadedChunks is a SET, that contains Flags for each
Sub-RECORD. They are set if the Sub-RECORD contains legal (loaded)
data.
IFF8SVXInfo.next/prev is unused. You can use it to link several
Sounds.
IFF8SVXInfo.VHDR contains important information on the sound like
it's volume, size, samplerate etc.
IFF8VSXInfo.NAME/COPY/AUTH/ANNO contain a pointer to a string and it's
size. The string is an ARRAY[0..999] OF CHAR, but there is just as
much memory allocated as needed.
IFF8SVXInfo.ATAK/RLSE contain information on the duration and
volume of a sound's attack and release. PlaySample ignores
these RECORDs.
IFF8SVXInfo.BODY contains the sounddata. Moreover, there is information
on whether there's just one block of data per Octave (MaxChunkSize=0),
whether the allocated memory is all chip-memory and on the biggest
chunk's size. There can be up to 8 Octaves saved here. For each Octave
there's a linked list of IFF8SVXLoad.DataChunk's, that each contain a
pointer to their data and the data's size.
IFF8SVXError:
Contains the last ErrorNumber (IFF8SVXErrs).
Errors:
iff8OK --> last command was successfully.
iff8OutOfMem --> system ran out of memory.
iff8Openfailed --> Dos.Open() didn't succeed. --> Dos.IOErr().
iff8Readfailed --> Dos.Read() didn't succeed. --> Dos-IOErr().
iff8NoIFF --> File is no IFF-sampled-Sound.
iff8NoChannel --> There's no more free Soundchannel.
iff8OpenDevicefailed --> OpenDevice() failed.
More detailed information on the variables and types can be seen in the
definition module.
Example-Programs:
---------------------
- PlaySample: Loads and plays the sound selected by Shift-Click or given
as an CLI-argument.
- PlayAll: Plays a sound like PlaySample does. If the sound
contains several octaves, the 4 lowest one will be played
simoultaneously.
- PlayKey: PlayKey has to be started like PlaySample. After it has
loaded the sound you can play it with different sampling-
rates by pressing different keys.
- PlayKanon: Plays a sample on all channels with 0.5s delay each.
- PlayRep: Repeats a sampled sound endless.
Copyright:
--------------
IFF8SVXLoad and it's demonstration-programs are Public Domain. They
are free to be copied and spread as long as you leave the author's
name in. Furthermore it's procedures are free to be imported by other
PD-Programs and spread this way.
If you make any changes in the programs, you can add a :History. line
in the program's head and put your name and the date in, but you are
not allowed to remove my name.
You are not allowed to make any profit with IFF8SVXLoad or changed
versions of IFF8SVXLoad without the author's permission!
Donations are wellcome!
--- Fridtjof.